package com.tender.service.impl;

import com.tender.service.SecurityService;
import com.tender.tools.DigestsUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SecurityServiceImpl implements SecurityService {

    @Override
    public List<String> findPermissionByLoginName(String loginName) {
        List<String> list = new ArrayList<>();
        if ("tender".equals(loginName)){
            list.add("order:list");
            list.add("order:add");
            list.add("order:del");
        }
        return list;
    }

    @Override
    public Map<String,String> findPasswordByLoginName(String loginName) {
        // return DigestsUtil.encryptPassword("123");
        Map<String, String> map = new HashMap<>();
        map.put("salt","ca776d8fa9abf4d22bc93cc547086284");
        map.put("password","958f8b90f3af8ad02b15d7284d0b3d31766e8ce7");
        return map;
    }

    @Override
    public List<String> findRoleByLoginName(String loginName) {
        List<String> list = new ArrayList<>();
        if ("admin".equals(loginName)){
            // 如果是 admin 登录，赋予 admin 的角色
            list.add("admin");
        }
        list.add("dev");
        return list;
    }

}
